const app = require('./app');
const path = require('path');
const bodyParser = require('body-parser');

const { db } = require('./lib');

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
    extended: false
}));

app.use((req, res, next) => {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
})

app.get('/', (req, res) => {
    res.sendFile(path.join(__dirname, '../public/index.html'))
});

// piper接口
app.use('/piper', require('./routes/piper'));


